package com.atguigu.b_test;

import java.util.Arrays;
/*
    不创建新数组 对原数组元素进行翻转
 */
public class Test7 {
    public static void main(String[] args) {
        int[] arr = {1,2,3,4,5};

        System.out.println("翻转前 : " + Arrays.toString(arr));

        //联动for循环
        for(int start = 0,end = arr.length - 1;start < end; start++,end--){
            //交换元素
            int temp = arr[start];
            arr[start] = arr[end];
            arr[end] = temp;
        }

        System.out.println("翻转后 : " + Arrays.toString(arr));
    }
}
